# 说明
refresh_token
用来获取新的 access_token,有效期两周
。使用方法下面有详细说明。
# 启用了 refresh_token 时,使用code换取access_token,会有 refresh_token字段
{
"status": 1,
"data": {
"access_token": "78b6bc08f05b4b79599d50a7b0188a3e107a7cde",
"expires_in": 7200,
"token_type": "Bearer",
"scope": "bug story",
"refresh_token": "d8c59e1c81b2739fecc16d58a2f60439f4b7b0b4",
"resource": {
"type": "workspace",
"workspace_id": 10104801
},
"now": "2019-06-14 16:14:00"
},
"info": "success"
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 使用 refresh_token 换取新的 access_token
# 请求 URL
https://apiv2.tapd.tencent.com/tokens/refresh_token
# 请求方法
POST
# 参数要求
# POST 参数
参数 | 说明 |
---|---|
grant_type | 必须取值 refresh_token |
refresh_token | 返回的 refresh_token 参数 |
# 其它参数
假设发放的 client_id
为 Aladdin
,client_secret
为open sesame
,则处理步骤举例如下:
- 将
Aladdin:open sesame
通过 BASE64 编码为:QWxhZGRpbjpvcGVuIHNlc2FtZQ==
- 写入 HTTP 头部的 Authorization 信息为:
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
1
# 返回
返回参数 | 参数说明 |
---|---|
access_token | 访问 API 的凭据 |
expires_in | 有效时长,单位为秒 |
token_type | 凭据类型,都是 Bearer |
scope | 接口范围 |
refresh_token | 用来获取新的 access_token,有效期两周 。使用方法下面有详细说明 |
resource | 项目权限范围 |
now | 服务器当前时间 |
# 示例
# 示例请求
curl -u "client_id:client_secret" -d "grant_type=refresh_token&refresh_token=5030faf7295219a36467db41dd92a0d5c2266da6" "https://apiv2.tapd.tencent.com/tokens/refresh_token"
# 示例返回
{
"status": 1,
"data": {
"access_token": "78b6bc08f05b4b79599d50a7b0188a3e107a7cde",
"expires_in": 7200,
"token_type": "Bearer",
"scope": "bug story",
"refresh_token": "d8c59e1c81b2739fecc16d58a2f60439f4b7b0b4",
"resource": {
"type": "workspace",
"workspace_id": 10104801
},
"now": "2019-06-14 16:14:00"
},
"info": "success"
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16